OBJS_BOOTPACK = bootpack.obj asmlib.obj hankaku.obj graphic.obj dsctbl.obj \
		int.obj fifo.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj \
		mtask.obj file.obj shell.obj window.obj

TOOLPATH = ../../z_tools/
INCPATH = ../../z_tools/haribote/
ROOTPATH = ../

MAKE	 = $(TOOLPATH)make.exe -r
NASK 	 = $(TOOLPATH)nask.exe
CC	 	 = $(TOOLPATH)cc1.exe -I$(INCPATH) -Os -Wall -quiet -std=c99
GAS2NASK = $(TOOLPATH)gas2nask.exe -a
OBJ2BIM  = $(TOOLPATH)obj2bim.exe
MAKEFONT = $(TOOLPATH)makefont.exe
BIN2OBJ	 = $(TOOLPATH)bin2obj.exe
BIM2HRB  = $(TOOLPATH)bim2hrb.exe
EDIMG	 = $(TOOLPATH)edimg.exe
IMGTOL 	 = $(TOOLPATH)imgtol.com
GOLIB    = $(TOOLPATH)golib00.exe
RULEFILE = $(ROOTPATH)zinc.rul
COPY 	 = copy
DEL		 = del

# 默认操作

default :
	$(MAKE) boot.bin
	$(MAKE) zinc.sys

# 文件生成规则

boot.bin : boot.nas Makefile
	$(NASK) boot.nas boot.bin boot.lst

head.bin : head.nas Makefile
	$(NASK) head.nas head.bin head.lst

hankaku.bin : hankaku.txt Makefile
	$(MAKEFONT) hankaku.txt hankaku.bin

hankaku.obj : hankaku.bin Makefile
	$(BIN2OBJ) hankaku.bin hankaku.obj _hankaku

bootpack.bim : $(OBJS_BOOTPACK) Makefile
	$(OBJ2BIM) @$(RULEFILE) out:bootpack.bim stack:3136k map:bootpack.map \
		$(OBJS_BOOTPACK)

bootpack.hrb : bootpack.bim Makefile
	$(BIM2HRB) bootpack.bim bootpack.hrb 0

zinc.sys : head.bin bootpack.hrb Makefile
	copy /B head.bin+bootpack.hrb zinc.sys

# 一般规则

%.gas : %.c Makefile
	$(CC) -o $*.gas $*.c

%.nas : %.gas Makefile
	$(GAS2NASK) $*.gas $*.nas

%.obj : %.nas Makefile
	$(NASK) $*.nas $*.obj $*.lst

# 伪目标

.PHONY : clean src_only

clean : 
	-$(DEL) head.bin
	-$(DEL) hankaku.bin
	-$(DEL) *.lst
	-$(DEL) *.obj
	-$(DEL) *.hrb
	-$(DEL) *.map
	-$(DEL) *.bim

src_only :
	$(MAKE) clean
	-$(DEL) boot.bin
	-$(DEL) zinc.sys
